<template>
  <!-- 登陆界面 -->
  <div>
    <div>
      <form ref="form">
        <div>
          <input type="text" v-model="formMess.user_name" placeholder="账号" />
        </div>
        <div>
          <input type="password" v-model="formMess.user_password" placeholder="密码" />
        </div>
      </form>
      <div @click="add"> 提交 </div>
      <div style="color:red; text-align:center">在本地写token后直接刷新就可以跳进去</div>
      <!-- <button @click="ifno">一处</button> -->
    </div>
  </div>
</template>
<script>
import { login } from '@/api/index';
export default {
  name: 'App',
  data() {
    return {
      // 表单参数
      formMess: {
        user_name: 'admin',
        user_password: '123456',
        remember: true,
      },
    };
  },
  methods: {
    // 登录事件(如于不同请自行替换)
    add() {
      login(this.formMess)
        .then((res) => {
          console.log(res, 'asdasd');
          this.$router.replace('/');
        })
        .catch((erroo) => {
          console.log(erroo, 'asdasd');
        });
      // let form = new FormData();
      // for (let i in this.formMess) {
      //   if (this.formMess[i] !== null && this.formMess[i] !== undefined) {
      //     form.append(i, this.formMess[i]);
      //   }
      // }
      // this.$ajax('?s=Manage.Brac_User.Login', this.formMess, function (res) {
      //   console.log(res);
      //   if (res.code == 200) {
      //     setToken(res.data.token);
      //     this.$router.replace('/');
      //   }
      // });
    },
    // 移除token方法调用
    ifno() {
      this.$store.dispatch('user/removeToken');
    },
  },
  created() {},
};
</script>
<style scoped>
.ifoadwda {
  display: flex;
}
>>> .ifoadwda > div {
  border: 1px solid red;
}
</style>
